﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CommunicationProtocol.dto.command.client
{
    public class PlantAPlant : Command
    {
        public short targetPlantId { get; }
        public int column { get; }
        public int row { get; }


        public PlantAPlant(byte[] remainingBytes) : base(3)
        {
            targetPlantId = BitConverter.ToInt16(remainingBytes, 0);
            column = BitConverter.ToInt32(remainingBytes, 2);
            row = BitConverter.ToInt32(remainingBytes, 6);
        }

        public PlantAPlant(short targetPlantId, int x, int y) : base(3)
        {
            this.targetPlantId = targetPlantId;
            column = x;
            row = y;
        }

        public override byte[] GetBytes()
        {
            return new byte[] {functionCode}.Concat(
                    BitConverter.GetBytes(targetPlantId)
                )
                .Concat(
                    BitConverter.GetBytes(column)
                )
                .Concat(
                    BitConverter.GetBytes(row)
                )
                .ToArray();
        }
    }
}